var gznrObj_ = {};
var ac1 = [];
var wxd1 = [];
var zj1 = [];
var zjObj1 = {};
var param = {};
var param1 = [];
var ticketType = "";
var detailId = "";
var fjId = new Array();
var wxdId = new Array();
var fjID = "";
var sadId = new Array();
var startTime1;
var endTime1;
var gznr_Data = {};
var acData_Data = {};
var wxd_Data = {};
var gzzj_Data = {};

function submitBox1() {
	ticketType = localStorage.getItem('ticketType');
	console.log("ticketType&&submit===" + ticketType);
	console.log('  detailId====' + localStorage.getItem('detailId') + "  fjId====" + localStorage.getItem('fjId') + "  wxdId==== " + localStorage.getItem('wxdId') + "  fjID==== " + localStorage.getItem('fjID') + "  sadId==== " + localStorage.getItem('sadId'));
	if(localStorage.getItem('detailId')) { // 基础数据id
		console.log(1);
		detailId = localStorage.getItem('detailId');
		param['gzp.id'] = detailId;
	}
	if(localStorage.getItem('fjID')) {
		console.log(2);
		fjID = localStorage.getItem('fjID');
		if(ticketType == "FJP") {
			param['fj.id'] = fjID;
		} else if(ticketType == "XL01") {
			param['xl01.id'] = fjID;
		} else if(ticketType == "SY01") {
			param['sy01.id'] = fjID;
		} else if(ticketType == "SY02") {
			param['sy02.id'] = fjID;
		}
	}
	console.log(localStorage.getItem('fjId'));
	if(localStorage.getItem('fjId')) {
		console.log(3);
		fjId = JSON.parse(localStorage.getItem('fjId'));
		console.log('fiId=====' + fjId.length);
		$.each(fjId, function(i, v) {
			param['gzzj[' + i + '].id'] = v;
		});
		console.log('3.1');
	}
	if(localStorage.getItem('wxdId')) {
		console.log(4);
		wxdId = JSON.parse(localStorage.getItem('wxdId'));
		$.each(wxdId, function(i, v) {
			param['wxd[' + i + '].id'] = v;
		});
	}
	if(localStorage.getItem('sadId')) {
		console.log(5);
		sadId = JSON.parse(localStorage.getItem('sadId'));
		$.each(sadId, function(i, v) {
			param['ac[' + i + '].id'] = v;
		});
	}

	param.gzpType = ticketType;
	gznrObj_ = JSON.parse(localStorage.getItem('gznr'));
	console.log('gznrObj_*****'+JSON.stringify(gznrObj_))
	if(gznrObj_.fcbh == null || gznrObj_.fcbh == "" || gznrObj_.fcbh == "请选择风场") {
		mui.toast('请选择风场编号!');
		return;
	}
	if(gznrObj_.gzpbh == null || gznrObj_.gzpbh == "") {
		gznrObj_.gzpbh = "";
	}
	if(gznrObj_.gzbz == null || gznrObj_.gzbz == "") {
		mui.toast('请选择工作班组人员!');
		//		gznrObj_.gzbz = "";
		return;
	}
	if(gznrObj_.jsr == "" || JSON.parse(gznrObj_.jsr).length == 0 || JSON.parse(gznrObj_.jsr) == null) {
		mui.toast('请选择下一环节接受人员!');
		//		gznrObj_.gzbz = "";
		return;
	}

	//	var reg = /^\+?[1-9][0-9]*$/;
	//	if(reg.test(gznrObj_.gzbzNum) == false) {
	//		mui.toast('人数只允许输入大于零的整数!');
	//		return;
	//	}

	if(gznrObj_.gzfzr == null || gznrObj_.gzfzr == "") {
		gznrObj_.gzfzr = "";
	}
	if(gznrObj_.yhzt == null || gznrObj_.yhzt == "") {
		gznrObj_.yhzt = "";
	}
	if(gznrObj_.startTime == null || gznrObj_.startTime == "请选择开始时间" || gznrObj_.startTime == "") {
		mui.toast('请选择计划开始时间!');
		return;
	}
	if(gznrObj_.endTime == null || gznrObj_.endTime == "" || gznrObj_.endTime == "请选择结束时间") {
		mui.toast('请选择计划结束时间!');
		return;
	}
	var startTime1 = new Date(gznrObj_.startTime.replace(/-/g, '/'));
	var endTime1 = new Date(gznrObj_.endTime.replace(/-/g, '/'));
	console.log("startTime1=" + startTime1 + "||endTime1=" + endTime1);
	if(startTime1 >= endTime1) {
		mui.toast('结束时间需大于开始时间!');
		return;
	}
	if(gznrObj_.sbmc1 == null || gznrObj_.sbmc1 == "" || gznrObj_.sbmc2 == null || gznrObj_.sbmc2 == "") {
		mui.toast('请填写设备双名称!');
		return;
	}
	if(gznrObj_.gznr == null || gznrObj_.gznr == "") {
		mui.toast('请输入工作地点!');
		return;
	}
	//	if(gznrObj_.sbmc1 == null || gznrObj_.sbmc1 == "" || gznrObj_.sbmc2 == null || gznrObj_.sbmc2 == "") {
	//		mui.toast('请填写设备双名称!');
	//		return;
	//	}
	//	console.log("灯塔==="+gznrObj_.dt);
	//	if(gznrObj_.dt == null || (gznrObj_.dt != "0" || gznrObj_.dt != "1")) {
	//		console.log("请选择灯塔");
	//		mui.toast('请选择灯塔');
	//		return;
	//	}else {
	//		console.log("1");
	//	}

	if(ticketType == "FJP") {
		if(gznrObj_.gznr == null || gznrObj_.gznr == "") {
			mui.toast('请输入工作内容!');
			return;
		}
		//		if(gznrObj_.fjbh == null || gznrObj_.fjbh == "") {
		//			mui.toast('请填写风机编号!');
		//			return;
		//		}
	} else if(ticketType == "XL01") {
		//		if(gznrObj_.gznr == null || gznrObj_.gznr == "") {
		//			mui.toast('请输入工作地点!');
		//			return;
		//		}
		if(gznrObj_.fjbh == null || gznrObj_.fjbh == "") {
			mui.toast('请输入工作内容!');
			return;
		}
	} else if(ticketType == "SY01") {
		if(gznrObj_.gznr == null || gznrObj_.gznr == "") {
			mui.toast('请输入工作内容!');
			return;
		}
		//		if(gznrObj_.fjbh == null || gznrObj_.fjbh == "") {
		//			mui.toast('请输入工作地点!');
		//			return;
		//		}
	} else if(ticketType == "SY02") {
		if(gznrObj_.gznr == null || gznrObj_.gznr == "") {
			mui.toast('请输入工作内容!');
			return;
		}
		//		if(gznrObj_.fjbh == null || gznrObj_.fjbh == "") {
		//			mui.toast('请输入工作地点!');
		//			return;
		//		}
	}
	console.log("173++++gznrObj_====" + JSON.stringify(gznrObj_));
	console.log('173+++gznrObj_.gzpbh===' + gznrObj_.gzpbh);
	if(gznrObj_) {
		param['gdId'] = gznrObj_.gdId;
		param['gzp.wind'] = gznrObj_.fcbh;
		param['gzp.depno'] = "";
		param['gzp.arbpl'] = gznrObj_.gzzx;
		param['gzp.ktext'] = gznrObj_.gzzxms;
		param['gzp.gzpnum'] = gznrObj_.gzpbh;
		param['userIds'] = gznrObj_.jsr;
		param['gzp.gzpgroup'] = gznrObj_.gzbz;
		param['gzp.gzpgroups'] = gznrObj_.gzbzNum;
		param['gzp.gzpfzr'] = gznrObj_.gzfzr;
		param['gzp.tsdate'] = gznrObj_.startTime.split(' ')[0];
		param['gzp.tstime'] = gznrObj_.startTime.split(' ')[1];
		param['gzp.tfdate'] = gznrObj_.endTime.split(' ')[0];
		param['gzp.tftime'] = gznrObj_.endTime.split(' ')[1];

		param['gzp.tplnr'] = gznrObj_.sbmc1;
		param['gzp.pltxt'] = gznrObj_.sbmc2;

		param['gzp.gznr'] = gznrObj_.gznr;
		param['gzp.fjbh'] = gznrObj_.fjbh;
		var startTime1 = new Date(gznrObj_.startTime.replace(/-/g, '/'));
		var qfsj = new Date(gznrObj_.qfsj.replace(/-/g, '/'));
		var xksj1 = new Date(gznrObj_.xksj.replace(/-/g, '/'));
//		alert(qfsj);
//		alert(gznrObj_.qfsj);
		if(qfsj > startTime1) {
			mui.toast('签发时间不能大于计划时间!');
			return;
		}
		if(xksj1 < startTime1) {
			mui.toast('计划开始时间不能大于许可时间!');
			return;
		}
		if(ticketType == "FJP") {

			param['fj.p19'] = gznrObj_.gzqfr; // 签发人
			if(gznrObj_.qfsj.split(" ").length == 1) {
				param['fj.d15'] = ""; // 签发日期
				param['fj.t15'] = ""; // 签发时间

			} else {
				param['fj.d15'] = gznrObj_.qfsj.split(" ")[0]; // 签发日期
				param['fj.t15'] = gznrObj_.qfsj.split(" ")[1]; // 签发时间
			}
			param['fj.p01'] = gznrObj_.fzr; // 负责人
			param['fj.p02'] = gznrObj_.xkr; // 许可人
			param['fj.C14'] = gznrObj_.gztj;//工作条件
			if(gznrObj_.xksj.split(" ").length == 1) {
				param['fj.d01'] = ""; // 许可日期
				param['fj.t01'] = ""; // 许可时间

			} else {
				param['fj.d01'] = gznrObj_.xksj.split(" ")[0]; // 许可日期
				param['fj.t01'] = gznrObj_.xksj.split(" ")[1]; // 许可时间
			}

		} else if(ticketType == "XL01") {

			param['xl01.p19'] = gznrObj_.gzqfr; // 签发时间
			if(gznrObj_.qfsj.split(" ").length == 1) {
				param['xl01.d15'] = ""; // 签发日期
				param['xl01.t15'] = ""; // 签发时间

			} else {
				param['xl01.d15'] = gznrObj_.qfsj.split(" ")[0]; // 签发日期
				param['xl01.t15'] = gznrObj_.qfsj.split(" ")[1]; // 签发时间
			}
			param['xl01.d15'] = gznrObj_.qfsj.split(" ")[0]; // 签发日期 
			param['xl01.t15'] = gznrObj_.qfsj.split(" ")[1]; // 签发时间
			param['xl01.p01'] = gznrObj_.fzr; // 负责人
			param['xl01.p02'] = gznrObj_.xkr; // 许可人
			param['xl01.C14'] = gznrObj_.gztj;//工作条件
			if(gznrObj_.xksj.split(" ").length == 1) {
				param['xl01.d01'] = ""; // 许可日期
				param['xl01.t01'] = ""; // 许可时间

			} else {
				param['xl01.d01'] = gznrObj_.xksj.split(" ")[0]; // 许可日期
				param['xl01.t01'] = gznrObj_.xksj.split(" ")[1]; // 许可时间
			}
		} else if(ticketType == "SY01") {
			param['sy01.p19'] = gznrObj_.gzqfr; // 签发时间
			if(gznrObj_.qfsj.split(" ").length == 1) {
				param['sy01.d15'] = ""; // 签发日期
				param['sy01.t15'] = ""; // 签发时间

			} else {
				param['sy01.d15'] = gznrObj_.qfsj.split(" ")[0]; // 签发日期
				param['sy01.t15'] = gznrObj_.qfsj.split(" ")[1]; // 签发时间
			}
			param['sy01.p01'] = gznrObj_.fzr; // 负责人
			param['sy01.p02'] = gznrObj_.xkr; // 许可人
			param['sy01.C14'] = gznrObj_.gztj;//工作条件
			if(gznrObj_.xksj.split(" ").length == 1) {
				param['sy01.d01'] = ""; // 许可日期
				param['sy01.t01'] = ""; // 许可时间

			} else {
				param['sy01.d01'] = gznrObj_.xksj.split(" ")[0]; // 许可日期
				param['sy01.t01'] = gznrObj_.xksj.split(" ")[1]; // 许可时间
			}
		} else if(ticketType == "SY02") {
			param['sy02.p19'] = gznrObj_.gzqfr; // 签发人
//			alert(gznrObj_.qfsj);
			if(gznrObj_.qfsj.split(" ").length == 1) {
				param['sy02.d15'] = ""; // 签发日期
				param['sy02.t15'] = ""; // 签发时间

			} else {
				param['sy02.d15'] = gznrObj_.qfsj.split(" ")[0]; // 签发日期
				param['sy02.t15'] = gznrObj_.qfsj.split(" ")[1]; // 签发时间
			}
			param['sy02.p01'] = gznrObj_.fzr; // 负责人
			param['sy02.p02'] = gznrObj_.xkr; // 许可人
			param['sy02.C14'] = gznrObj_.gztj;//工作条件
			if(gznrObj_.xksj.split(" ").length == 1) {
				param['sy02.d01'] = ""; // 许可日期
				param['sy02.t01'] = ""; // 许可时间

			} else {
				param['sy02.d01'] = gznrObj_.xksj.split(" ")[0]; // 许可日期
				param['sy02.t01'] = gznrObj_.xksj.split(" ")[1]; // 许可时间
			}
		}
	}
	ac1 = JSON.parse(localStorage.getItem('ac'));
	console.log("ac1===" + JSON.stringify(ac1));
	if(localStorage.getItem('ac') && ac1.length > 0) {
		console.log('ac已经接收到');
		$.each(JSON.parse(localStorage.getItem('ac')), function(i, v) {
			param['ac[' + i + '].safelx'] = v.ac;
			param['ac[' + i + '].zcode'] = v.zcode;
			param['ac[' + i + '].aqqdtyp'] = v.aqqdtyp;
			param['ac[' + i + '].acfyTypeId'] = v.acfyTypeId;
		});
		console.log('ac已经接收完毕');
	}
	if(ac1.length == 0) {
		mui.toast('请选择安全措施!');
		return;
	}
//	图片信息
	Image1 = JSON.parse(localStorage.getItem('Image'));
	console.log("Image===" + JSON.stringify(Image1));
	if(localStorage.getItem('Image') && Image1.length > 0) {
		console.log('Image1已经接收到');
		$.each(JSON.parse(localStorage.getItem('Image')), function(i, v) {
			param['Image[' + i + '].attach'] = v.attach;
		});
		console.log('Image1已经接收完毕');
	}
	/*if(ac1.length == 0) {
		mui.toast('请选择安全措施!');
		return;
	}*/
//	图片信息结束
	wxd1 = JSON.parse(localStorage.getItem('wxd'));
	console.log('wxd1====' + wxd1);
	if(localStorage.getItem('wxd')) {
		console.log('wxd已经接收到！');
//		$.each(JSON.parse(localStorage.getItem('wxd')), function(i, v) {
			param['wxdArray'] = localStorage.getItem('wxd');
			/*param['wxd[' + i + '].ztext1'] = v.ztext1;
			param['wxd[' + i + '].wxdArray'] = v.wxdArray;*/
//		});
	}
	//	if(wxd1.length == 0) {
	//		mui.toast('请选择危险点控制!');
	//		return;
	//	}

	console.log("zjObj1=====" + localStorage.getItem('zj1'));
	zjObj1 = JSON.parse(localStorage.getItem('zj1'));
	if(zjObj1) {
		//是否灯塔
		if(zjObj1.dt) {
			param['gzp.isdengta'] = zjObj1.dt;
		} else {
			param['gzp.isdengta'] = "";
		}

		if(ticketType == "FJP") {

			if(zjObj1.endTime) {
				console.log("zjObj1.endTime=" + zjObj1.endTime);
				console.log("===================");
				param['fj.d09'] = zjObj1.endTime.split(' ')[0];
				param['fj.t09'] = zjObj1.endTime.split(' ')[1];
			} else {
				console.log("-----------------------");
				param['fj.d09'] = "";
				param['fj.t09'] = "";
			}
			param['fj.p13'] = zjObj1.dutyer;
			param['fj.p14'] = zjObj1.permit;
			param['fj.c17'] = zjObj1.jiaodi;
		} else if(ticketType == "XL01") {
			if(zjObj1.endTime) {
				param['xl01.d09'] = zjObj1.endTime.split(' ')[0];
				param['xl01.t09'] = zjObj1.endTime.split(' ')[1];
			} else {
				param['xl01.d09'] = "";
				param['xl01.t09'] = "";
			}
			//			param['xl01.t09'] = "";
			param['xl01.p13'] = zjObj1.dutyer;
			param['xl01.p14'] = zjObj1.permit;
		} else if(ticketType == "SY01") {
			if(zjObj1.endTime) {
				param['sy01.d09'] = zjObj1.endTime.split(' ')[0];
				param['sy01.t09'] = zjObj1.endTime.split(' ')[1];
			} else {
				param['sy01.d09'] = "";
				param['sy01.t09'] = "";
			}
			param['sy01.p13'] = zjObj1.dutyer;
			param['sy01.p14'] = zjObj1.permit;
		} else if(ticketType == "SY02") {
			if(zjObj1.endTime) {
				param['sy02.d09'] = zjObj1.endTime.split(' ')[0];
				param['sy02.t09'] = zjObj1.endTime.split(' ')[1];
			} else {
				param['sy02.d09'] = "";
				param['sy02.t09'] = "";
			}
			param['sy02.p13'] = zjObj1.dutyer;
			param['sy02.p14'] = zjObj1.permit;

			//		if(zjObj1.endTime == null || zjObj1.endTime == undefined || zjObj1.endTime == "" || zjObj1.endTime == "请选择时间") {
			//			mui.toast('请选择工作票结束时间!');
			//			return;
		}

	}

	if(localStorage.getItem('zj')) {
		console.log('风机服役已经接受到！' + JSON.stringify(localStorage.getItem('zj')));
		$.each(JSON.parse(localStorage.getItem('zj')), function(i, v) {
			param['gzzj[' + i + '].opcont'] = v.zj;
			param['gzzj[' + i + '].opchk'] = v.aqqdtyp;
		});

	}

	console.log('287-----param', JSON.stringify(param));

	if(detailId) {
		console.log('detailId存在');
	} else {
		//		console.log('新建工作票的保存！');
		localStorage.setItem('param', JSON.stringify(param));
	}
	setTimeout(function() {
		submitAjax();
	}, 200);

};

function submitBox2() {
	ticketType = localStorage.getItem('ticketType');
	console.log("ticketType&&submit===" + ticketType);
	console.log('  detailId====' + localStorage.getItem('detailId') + "  fjId====" + localStorage.getItem('fjId') + "  wxdId==== " + localStorage.getItem('wxdId') + "  fjID==== " + localStorage.getItem('fjID') + "  sadId==== " + localStorage.getItem('sadId'));
	if(localStorage.getItem('detailId')) { // 基础数据id
		console.log(1);
		detailId = localStorage.getItem('detailId');
		param['gzp.id'] = detailId;
	}
	if(localStorage.getItem('fjID')) {
		console.log(2);
		fjID = localStorage.getItem('fjID');
		if(ticketType == "FJP") {
			param['fj.id'] = fjID;
		} else if(ticketType == "XL01") {
			param['xl01.id'] = fjID;
		} else if(ticketType == "SY01") {
			param['sy01.id'] = fjID;
		} else if(ticketType == "SY02") {
			param['sy02.id'] = fjID;
		}
	}
	console.log(localStorage.getItem('fjId'));
	if(localStorage.getItem('fjId')) {
		console.log(3);
		fjId = JSON.parse(localStorage.getItem('fjId'));
		console.log('fiId=====' + fjId.length);
		$.each(fjId, function(i, v) {
			param['gzzj[' + i + '].id'] = v;
		});
		console.log('3.1');
	}
	if(localStorage.getItem('wxdId')) {
		console.log(4);
		wxdId = JSON.parse(localStorage.getItem('wxdId'));
		$.each(wxdId, function(i, v) {
			param['wxd[' + i + '].id'] = v;
		});
	}
	if(localStorage.getItem('sadId')) {
		console.log(5);
		sadId = JSON.parse(localStorage.getItem('sadId'));
		$.each(sadId, function(i, v) {
			param['ac[' + i + '].id'] = v;
		});
	}

	param.gzpType = ticketType;
	gznrObj_ = JSON.parse(localStorage.getItem('gznr'));
	if(gznrObj_.fcbh == null || gznrObj_.fcbh == "" || gznrObj_.fcbh == "请选择风场") {
		mui.toast('请选择风场编号!');
		return;
	}
	if(gznrObj_.gzpbh == null || gznrObj_.gzpbh == "") {
		gznrObj_.gzpbh = "";
	}
	//	if(gznrObj_.jsr.length == 0 || gznrObj_.jsr == null) {
	//		gznrObj_.jsr = "";
	//	}
	if(gznrObj_.gzbz == null || gznrObj_.gzbz == "") {
		gznrObj_.gzbz = "";
	}

	if(gznrObj_.gzfzr == null || gznrObj_.gzfzr == "") {
		gznrObj_.gzfzr = "";
	}
	if(gznrObj_.yhzt == null || gznrObj_.yhzt == "") {
		gznrObj_.yhzt = "";
	}
	if(gznrObj_.startTime == null || gznrObj_.startTime == "请选择开始时间") {
		mui.toast('请选择计划开始时间!');
		return;
	}
	if(gznrObj_.endTime == null || gznrObj_.endTime == "" || gznrObj_.endTime == "请选择结束时间") {
		mui.toast('请选择计划结束时间!');
		return;
	}
	//	var startTime1 = new Date(gznrObj_.startTime.replace(/-/g, '/'));
	//	var endTime1 = new Date(gznrObj_.endTime.replace(/-/g, '/'));
	//	console.log("startTime1=" + startTime1 + "||endTime1=" + endTime1);
	//	if(startTime1 > endTime1) {
	//		mui.toast('开始时间不能大于结束时间!');
	//		return;
	//	}
	//	if(gznrObj_.sbmc1 == null || gznrObj_.sbmc1 == "" || gznrObj_.sbmc2 == null || gznrObj_.sbmc2 == "") {
	//		mui.toast('请填写设备双名称!');
	//		return;
	//	}
	//	if(gznrObj_.dt == null || gznrObj_.dt == "") {
	//		mui.toast('请选择灯塔');
	//		return;
	//	}
	if(ticketType == "FJP") {
		if(gznrObj_.gznr == null || gznrObj_.gznr == "") {
			mui.toast('请输入工作内容!');
			return;
		}
		if(gznrObj_.fjbh == null || gznrObj_.fjbh == "") {
			mui.toast('请填写风机编号!');
			return;
		}
	} else if(ticketType == "XL01") {
		if(gznrObj_.gznr == null || gznrObj_.gznr == "") {
			mui.toast('请输入工作地点!');
			return;
		}
		if(gznrObj_.fjbh == null || gznrObj_.fjbh == "") {
			mui.toast('请输入工作内容!');
			return;
		}
	} else if(ticketType == "SY01") {
		if(gznrObj_.gznr == null || gznrObj_.gznr == "") {
			mui.toast('请输入工作内容!');
			return;
		}
		if(gznrObj_.fjbh == null || gznrObj_.fjbh == "") {
			mui.toast('请输入工作地点!');
			return;
		}
	} else if(ticketType == "SY02") {
		if(gznrObj_.gznr == null || gznrObj_.gznr == "") {
			mui.toast('请输入工作内容!');
			return;
		}
		if(gznrObj_.fjbh == null || gznrObj_.fjbh == "") {
			mui.toast('请输入工作地点!');
			return;
		}
	}
	console.log("527++++gznrObj_====" + JSON.stringify(gznrObj_));
	console.log('529+++gznrObj_.gzpbh===' + gznrObj_.gzpbh);
	if(gznrObj_) {
		param['gdId'] = gznrObj_.gdId;
		param['gzp.wind'] = gznrObj_.fcbh;
		param['gzp.depno'] = "";
		param['gzp.arbpl'] = gznrObj_.gzzx;
		param['gzp.ktext'] = gznrObj_.gzzxms;
		param['gzp.gzpnum'] = gznrObj_.gzpbh;
		param['gzp.gzpgroup'] = gznrObj_.gzbz;
		param['userIds'] = gznrObj_.jsr;
		param['gzp.gzpgroups'] = gznrObj_.gzbzNum;
		param['gzp.gzpfzr'] = gznrObj_.gzfzr;
		param['gzp.tsdate'] = gznrObj_.startTime.split(' ')[0];
		param['gzp.tstime'] = gznrObj_.startTime.split(' ')[1];
		param['gzp.tfdate'] = gznrObj_.endTime.split(' ')[0];
		param['gzp.tftime'] = gznrObj_.endTime.split(' ')[1];

		param['gzp.tplnr'] = gznrObj_.sbmc1;
		param['gzp.pltxt'] = gznrObj_.sbmc2;

		param['gzp.gznr'] = gznrObj_.gznr;
		param['gzp.fjbh'] = gznrObj_.fjbh;
		if(ticketType == "FJP") {

			param['fj.p19'] = gznrObj_.gzqfr; // 签发人
			if((gznrObj_.qfsj).split(" ").length == 1) {
				param['fj.d15'] = ""; // 签发日期
				param['fj.t15'] = ""; // 签发时间

			} else {
				param['fj.d15'] = gznrObj_.qfsj.split(" ")[0]; // 签发日期
				param['fj.t15'] = gznrObj_.qfsj.split(" ")[1]; // 签发时间
			}
			param['fj.p01'] = gznrObj_.fzr; // 负责人
			param['fj.p02'] = gznrObj_.xkr; // 许可人
			if(gznrObj_.xksj.split(" ").length == 1) {
				param['fj.d01'] = ""; // 许可日期
				param['fj.t01'] = ""; // 许可时间

			} else {
				param['fj.d01'] = gznrObj_.xksj.split(" ")[0]; // 许可日期
				param['fj.t01'] = gznrObj_.xksj.split(" ")[1]; // 许可时间
			}

		} else if(ticketType == "XL01") {

			param['xl01.p19'] = gznrObj_.gzqfr; // 签发时间
			if((gznrObj_.qfsj).split(" ").length == 1) {
				console.log("8888888888888888888888888888888888888888888888888888888888888888888888888888888");
				param['xl01.d15'] = ""; // 签发日期
				param['xl01.t15'] = ""; // 签发时间

			} else {
				console.log("999999999999999999999999999999999999999999999999999999999999999999999");
				param['xl01.d15'] = gznrObj_.xksj.split(" ")[0]; // 签发日期
				param['xl01.t15'] = gznrObj_.xksj.split(" ")[1]; // 签发时间
			}
			//			param['xl01.d15'] = gznrObj_.qfsj.split(" ")[0]; // 签发日期 
			//			param['xl01.t15'] = gznrObj_.qfsj.split(" ")[1]; // 签发时间
			param['xl01.p01'] = gznrObj_.fzr; // 负责人
			param['xl01.p02'] = gznrObj_.xkr; // 许可人
			if(gznrObj_.xksj.split(" ").length == 1) {
				param['xl01.d01'] = ""; // 许可日期
				param['xl01.t01'] = ""; // 许可时间

			} else {
				param['xl01.d01'] = gznrObj_.xksj.split(" ")[0]; // 许可日期
				param['xl01.t01'] = gznrObj_.xksj.split(" ")[1]; // 许可时间
			}
		} else if(ticketType == "SY01") {
			param['sy01.p19'] = gznrObj_.gzqfr; // 签发时间
			if(gznrObj_.qfsj.split(" ").length == 1) {
				param['sy01.d15'] = ""; // 签发日期
				param['sy01.t15'] = ""; // 签发时间

			} else {
				param['sy01.d15'] = gznrObj_.xksj.split(" ")[0]; // 签发日期
				param['sy01.t15'] = gznrObj_.xksj.split(" ")[1]; // 签发时间
			}
			param['sy01.p01'] = gznrObj_.fzr; // 负责人
			param['sy01.p02'] = gznrObj_.xkr; // 许可人
			if(gznrObj_.xksj.split(" ").length == 1) {
				param['sy01.d01'] = ""; // 许可日期
				param['sy01.t01'] = ""; // 许可时间

			} else {
				param['sy01.d01'] = gznrObj_.xksj.split(" ")[0]; // 许可日期
				param['sy01.t01'] = gznrObj_.xksj.split(" ")[1]; // 许可时间
			}
		} else if(ticketType == "SY02") {
			param['sy02.p19'] = gznrObj_.gzqfr; // 签发人
			if(gznrObj_.qfsj.split(" ").length == 1) {
				param['sy02.d15'] = ""; // 签发日期
				param['sy02.t15'] = ""; // 签发时间

			} else {
				param['sy02.d15'] = gznrObj_.xksj.split(" ")[0]; // 签发日期
				param['sy02.t15'] = gznrObj_.xksj.split(" ")[1]; // 签发时间
			}
			param['sy02.p01'] = gznrObj_.fzr; // 负责人
			param['sy02.p02'] = gznrObj_.xkr; // 许可人
			if(gznrObj_.xksj.split(" ").length == 1) {
				param['sy02.d01'] = ""; // 许可日期
				param['sy02.t01'] = ""; // 许可时间

			} else {
				param['sy02.d01'] = gznrObj_.xksj.split(" ")[0]; // 许可日期
				param['sy02.t01'] = gznrObj_.xksj.split(" ")[1]; // 许可时间
			}
		}
	}
	ac1 = JSON.parse(localStorage.getItem('ac'));
	console.log("ac1===" + JSON.stringify(ac1));
	if(localStorage.getItem('ac') && ac1.length > 0) {
		console.log('ac已经接收到');
		$.each(JSON.parse(localStorage.getItem('ac')), function(i, v) {
			param['ac[' + i + '].safelx'] = v.ac;
			param['ac[' + i + '].zcode'] = v.zcode;
		});
		console.log('ac已经接收完毕');
	}
	if(ac1.length == 0) {
		mui.toast('请选择安全措施!');
		return;
	}

	wxd1 = JSON.parse(localStorage.getItem('wxd'));
	console.log('wxd1====' + wxd1);
	if(localStorage.getItem('wxd')) {
		console.log('wxd已经接收到！');
		console.log("wxd=====" + localStorage.getItem('wxd'));
		$.each(JSON.parse(localStorage.getItem('wxd')), function(i, v) {
			param['wxd[' + i + '].fvalue'] = v.wxd;
			param['wxd[' + i + '].wxcode'] = v.zcode;
		});
	}
	if(wxd1.length == 0) {
		mui.toast('请选择危险点控制!');
		return;
	}

	console.log("445===zjObj1=====" + localStorage.getItem('zj1'));
	zjObj1 = localStorage.getItem('zj1');

	if(zjObj1) {
		//是否灯塔
		if(zjObj1.dt) {
			param['gzp.isdengta'] = zjObj1.dt;
		} else {
			param['gzp.isdengta'] = "";
		}

		if(ticketType == "FJP") {
			if(param['fj.d09']) {
				param['fj.d09'] = zjObj1.endTime.split(' ')[0];
				param['fj.t09'] = zjObj1.endTime.split(' ')[1];
			} else {
				param['fj.d09'] = "";
				param['fj.t09'] = "";
			}

			param['fj.p13'] = zjObj1.dutyer;
			param['fj.p14'] = zjObj1.permit;
			param['fj.c17'] = zjObj1.jiaodi;
		} else if(ticketType == "XL01") {
			if(param['xl01.d09']) {
				param['xl01.d09'] = zjObj1.endTime.split(' ')[0];
				param['xl01.t09'] = zjObj1.endTime.split(' ')[1];
			} else {
				param['xl01.d09'] = "";
				param['xl01.t09'] = "";
			}
			param['xl01.p13'] = zjObj1.dutyer;
			param['xl01.p14'] = zjObj1.permit;
		} else if(ticketType == "SY01") {
			if(param['sy01.d09']) {
				param['sy01.d09'] = zjObj1.endTime.split(' ')[0];
				param['sy01.t09'] = zjObj1.endTime.split(' ')[1];
			} else {
				param['sy01.d09'] = "";
				param['sy01.t09'] = "";
			}
			param['sy01.p13'] = zjObj1.dutyer;
			param['sy01.p14'] = zjObj1.permit;
		} else if(ticketType == "SY02") {
			if(param['sy02.d09']) {
				param['sy02.d09'] = zjObj1.endTime.split(' ')[0];
				param['sy02.t09'] = zjObj1.endTime.split(' ')[1];
			} else {
				param['sy02.d09'] = "";
				param['sy02.t09'] = "";
			}
			param['sy02.p13'] = zjObj1.dutyer;
			param['sy02.p14'] = zjObj1.permit;
		}

	} else {
		param['gzp.isdengta'] = zjObj1.dt;
		if(ticketType == "FJP") {
			param['fj.d09'] = "";
			param['fj.t09'] = "";
			param['fj.p13'] = "";
			param['fj.p14'] = "";
			param['fj.c17'] = "";
		} else if(ticketType == "XL01") {
			param['xl01.d09'] = "";
			param['xl01.t09'] = "";
			//			param['xl01.t09'] = "";
			param['xl01.p13'] = "";
			param['xl01.p14'] = "";
		} else if(ticketType == "SY01") {
			param['sy01.d09'] = "";
			param['sy01.t09'] = "";
			param['sy01.p13'] = "";
			param['sy01.p14'] = "";
		} else if(ticketType == "SY02") {
			param['sy02.d09'] = "";
			param['sy02.t09'] = "";
			param['sy02.p13'] = "";
			param['sy02.p14'] = "";
		}
	}

	zj1 = JSON.parse(localStorage.getItem('zj'));
	if(localStorage.getItem('zj')) {
		$.each(JSON.parse(localStorage.getItem('zj')), function(i, v) {
			param['gzzj[' + i + '].opcont'] = v.zj;
		});
	}
	//	if(zj1.length == 0) {
	//		mui.toast('请选择工作终结!');
	//		return;
	//	}

	console.log('287-----param', JSON.stringify(param));

	if(detailId) {
		console.log('detailId存在');
	} else {
		//		console.log('新建工作票的保存！');
		localStorage.setItem('param', JSON.stringify(param));
	}
	saveAjax();
};
// 提交的ajax请求
function submitAjax() {
	console.log('提交的方法被触发了！');
	plus.nativeUI.showWaiting('提交中...');
//	alert(JSON.stringify(param));
	console.log(param)
	mui.baseApp.httpRequst('/api/v2/gzpOrder/createGzpOrFlow', param,
		function(data) {
			plus.nativeUI.closeWaiting();
			if(data.status == '200') {
				mui.toast('提交成功!');

				if(localStorage.getItem('detailId')) { // 基础数据id
					console.log('进行的是流转提交');
					localStorage.removeItem('gznr');
					localStorage.removeItem('ac');
					localStorage.removeItem('wxd');
					localStorage.removeItem('zj1');
					localStorage.removeItem('zj');
					localStorage.removeItem('detailId');
					localStorage.removeItem('Image');
					localStorage.removeItem('fjId');
					localStorage.removeItem('wxdId');
					localStorage.removeItem('sadId');
					localStorage.removeItem('fjID');
					var workTicket = plus.webview.getWebviewById('workTicket_sub.html');
					if(workTicket) {
						workTicket.evalJS('pulldown()');
					}
					var network = plus.webview.getWebviewById('network.html');
					if(network) {
						network.evalJS('home()');
					}

					console.log("提交成功!" + JSON.stringify(data.data));
					mui.back();
					return
				} else {
					console.log("进行的是创建提交");
					var draft = new Draft();
					var index = localStorage.getItem('index');
					console.log("index====" + index);
					if(index) {
						draft.delete(index);
						localStorage.removeItem('index');
					}
					localStorage.removeItem('draftCtime');
					var list = plus.webview.getWebviewById('draft.html');
					if(list) {
						console.log("是从草稿箱列表进来的!");
						list.evalJS('date()');
					}
					localStorage.removeItem('gznr');
					localStorage.removeItem('ac');
					localStorage.removeItem('wxd');
					localStorage.removeItem('zj1');
					localStorage.removeItem('zj');
					localStorage.removeItem('detailId');
					localStorage.removeItem('fjId');
					localStorage.removeItem('wxdId');
					localStorage.removeItem('sadId');
					localStorage.removeItem('fjID');
					var workTicket = plus.webview.getWebviewById('workTicket_sub.html');
					if(workTicket) {
						workTicket.evalJS('pulldown()');
					}
					var network = plus.webview.getWebviewById('network.html');
					if(network) {
						network.evalJS('home()');
					}

					console.log("提交成功!" + JSON.stringify(data.data));
					mui.back();
					return
				}

			} else if(data.status == '500') {
				mui.toast('提交失败!');
				console.log("提交失败!");
			}
		},
		function(data) {
			plus.nativeUI.closeWaiting();
			console.log("提交失败,原因是 " + data);
		},'post');
}

//保存的ajax请求
function saveAjax() {
	plus.nativeUI.showWaiting('保存中...');
	mui.baseApp.httpRequst('/api/v2/gzpOrder/saveGZP', param,
		function(data) {
			plus.nativeUI.closeWaiting();
			if(data.status == '200') {
				mui.toast('保存成功!');
				localStorage.removeItem('gznr');
				localStorage.removeItem('ac');
				localStorage.removeItem('wxd');
				localStorage.removeItem('zj1');
				localStorage.removeItem('zj');
				localStorage.removeItem('detailId');
				localStorage.removeItem('fjId');
				localStorage.removeItem('wxdId');
				localStorage.removeItem('sadId');
				localStorage.removeItem('param1');
				console.log('保存成功之后 sadId=====' + localStorage.getItem('sadId'));
				localStorage.removeItem('fjID');
				var list = plus.webview.getWebviewById('workTicket_sub.html');
				if(list) {
					list.evalJS('pulldown()');
				}
				mui.back();
				console.log("保存成功!" + JSON.stringify(data.data));
			} else if(data.status == '500') {
				mui.toast('保存失败!');
				console.log("保存失败!");
				return
			}
		},
		function() {
			plus.nativeUI.closeWaiting();
			console.log("保存失败!");
		});

}

function submitBox3() {
	ticketType = localStorage.getItem('ticketType');
	console.log("ticketType&&submit===" + ticketType);
	console.log('  detailId====' + localStorage.getItem('detailId') + "  fjId====" + localStorage.getItem('fjId') + "  wxdId==== " + localStorage.getItem('wxdId') + "  fjID==== " + localStorage.getItem('fjID') + "  sadId==== " + localStorage.getItem('sadId'));

	param1.gzpType = ticketType;
	gznrObj_ = JSON.parse(localStorage.getItem('gznr'));
	param1.push(gznrObj_);
	console.log("877++++++gznrObj_====" + JSON.stringify(gznrObj_));

	ac1 = JSON.parse(localStorage.getItem('ac'));
	param1.push(ac1);
	console.log("ac1===" + JSON.stringify(ac1));

	wxd1 = JSON.parse(localStorage.getItem('wxd'));
	console.log('wxd1====' + wxd1);
	param1.push(wxd1);

	console.log("zjObj1=====" + localStorage.getItem('zj1'));
	zjObj1 = JSON.parse(localStorage.getItem('zj1'));
	param1.push(zjObj1);

	console.log("zj1=====" + localStorage.getItem('zj'));
	zj1 = JSON.parse(localStorage.getItem('zj'));
	param1.push(zj1);

	console.log('287-----param1', JSON.stringify(param1));

	//		console.log('新建工作票的保存！');
	//		localStorage.setItem('param1', JSON.stringify(param1));
	console.log('本地保存成功====' + param1[0].gznr);
	mui.toast('本地保存成功!');
	var draft = new Draft();

	function time(t) { // 转换时间格式
		var t = new Date();
		var y = t.getFullYear(); // 年
		var m = t.getMonth() + 1; // 月
		var d = t.getDate(); // 日
		var h = t.getHours(); // 时
		var ms = t.getMinutes(); // 分
		var s = t.getSeconds(); // 秒
		console.log(m + d + h + ms + s);
		if(m < 10) {
			m = "0" + m;
		}
		if(d < 10) {
			d = "0" + d;
		}
		if(h < 10) {
			h = "0" + h;
		}
		if(ms < 10) {
			ms = "0" + ms;
		}
		if(s < 10) {
			s = "0" + s;
		}
		var nowDate = y + "-" + m + "-" + d + " " + h + ":" + ms + ":" + s;
		return nowDate;
	}
	var ctime = "";
	console.log("work_submit.js=====" + localStorage.getItem('draftCtime'));
	if(localStorage.getItem('draftCtime')) {
		ctime = localStorage.getItem('draftCtime');
	} else {
		ctime = time(new Date);
	}
	var draftData = {}; // 保存的缓存数据
	console.log("creatTime..." + time(new Date));
	draftData = {
		type: 'gzp',
		title: param1[0].gznr,
		creatTime: ctime,
		data: param1
	}
	draft.save(draftData);
	localStorage.removeItem('draftCtime');
	var list = plus.webview.getWebviewById('draft.html');
	if(list) {
		console.log("是从草稿箱列表进来的!");
		list.evalJS('date()');
	}

	mui.back();

};